import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

import multidimensional.PlanarProjectionViewerFactory;

import Graph.Graph;
import Graph.GraphData;
import Graph.GraphDataFactory;
import Graph.GraphViewerFactory;
import Graph.ViewFocusGraphViewer;
import Graph.ViewFocusGraphViewerFactory;
import ParallelCoord.ParallelCoordinateViewerFactory;

import perspectives.*;
import perspectives.PropertyManager.OpenFile;
import perspectives.PropertyManager.Options;
import tree.*;
import util.Hotspots;
import util.HotspotsFactory;
import util.ImageTiler;
import util.ImageTilerFactory;

import data.*;
import eyetrack.shapematch.ShapeViewer;
import eyetrack.shapematch.ShapeViewerFactory;
import eyetrack.shapematch.task.ShapeTaskViewer;
import eyetrack.shapematch.task.ShapeTaskViewerFactory;


public class main {

	  public static void main(String[] args) {  
		  
		  Environment e = new Environment();
	    
	      e.registerViewerFactory(new GraphViewerFactory());
	       
	      e.registerDataSourceFactory(new GraphDataFactory());
	     e.registerDataSourceFactory(new TableDataFactory());
	       
	      e.registerViewerFactory(new RadialBrainConnectivityViewerFactory());
	      
	     e.registerViewerFactory(new PlanarProjectionViewerFactory());
	      
	      e.registerViewerFactory(new HierarchicalClusteringViewerFactory());
	      
	      e.registerViewerFactory(new GraphViewerFactory());
	      
	      e.registerViewerFactory(new ViewFocusGraphViewerFactory());
	      
	      e.registerViewerFactory(new ImageTilerFactory());
	      
	      e.registerViewerFactory(new HotspotsFactory());
	      
	      e.registerViewerFactory(new ParallelCoordinateViewerFactory());
	      
	      e.registerViewerFactory(new ShapeViewerFactory());
	      
	      e.registerViewerFactory(new ShapeTaskViewerFactory());
	      
	      if(args.length == 6 && args[0].equalsIgnoreCase("-view") && args[2].equalsIgnoreCase("-edgefile") && args[4].equalsIgnoreCase("-positionfile"))
	      {
	    	  GraphData data = new GraphData("FocusViewGraph");
	    	  Options formatOption = (Options) data.getProperty("Format").getValue();
	    	  formatOption.selectedIndex =1;
	    	  data.getProperty("Format").setValue(formatOption);
	    	  
	    	  OpenFile f = (OpenFile) data.getProperty("Graph File").getValue();
	    	  f.path = args[3];
	    	  data.getProperty("Graph File").setValue(f);
	    	  e.addDataSource(data);
	    	  
	    	 // data.graph.fromEdgeList(new File(args[3]))
	    	  
	    	  while (!data.isLoaded());
	    	  
	    	  ViewFocusGraphViewer focusView = new ViewFocusGraphViewer("view1", data);
	    	  
	    	  OpenFile positionFile = (OpenFile) focusView.getProperty("Load Positions").getValue();
	    	  positionFile.path = args[5];
	    	  
	    	  focusView.getProperty("Load Positions").setValue(positionFile);
	    	  
	    	  e.addViewer(focusView);
	      }
	      else if(args.length == 4 && args[0].equalsIgnoreCase("-view") && args[2].equalsIgnoreCase("-shapefile"))
	      {
	    	  ShapeViewer viewer = new ShapeViewer("Shape Viewer");
	    	  OpenFile shapeFile = (OpenFile) viewer.getProperty("Load Shape").getValue();
	    	  shapeFile.path = args[3];
	    	  viewer.getProperty("Load Shape").setValue(shapeFile);
	    	  e.addViewer(viewer);
	      }
	      else if(args.length == 4 && args[0].equalsIgnoreCase("-view") && args[2].equalsIgnoreCase("-taskfile"))
	      {
	    	  ShapeTaskViewer viewer = new ShapeTaskViewer("Shape Task Viewer");
	    	  OpenFile taskFile = (OpenFile) viewer.getProperty("Load Tasks").getValue();
	    	  taskFile.path = args[3];
	    	  viewer.getProperty("Load Tasks").setValue(taskFile);
	    	  e.addViewer(viewer);
	      }
	  }
	
	
}
